<link href="__PUBLIC__/corpper/css/cropper.min.css" rel="stylesheet"/>
<link href="__PUBLIC__/corpper/css/main.css" rel="stylesheet"/>
     
<div class="container" id="crop-avatar" style='width:100%'>
            <!-- Current avatar -->
            <div class="avatar-view " title="点击上传图片" style='width:20%;'>
                <img class='def-imgx' src="Public/corpper/img/picture.png" alt="图片"/>
            </div>
            <!-- Cropping modal -->
            <div class="modal fade" id="avatar-modal" aria-hidden="true" aria-labelledby="avatar-modal-label" role="dialog" tabindex="-1">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                        <div class="avatar-form">
                            <div class="modal-header">
                                <button class="close" data-dismiss="modal" type="button">&times;</button>
                                <h4 class="modal-title" id="avatar-modal-label">更换图片</h4>
                            </div>
                            <div class="modal-body">
                                <div class="avatar-body">

                                    <!-- Upload image and data -->
                                    <div class="avatar-upload">
                                        <input class="avatar-src" name="avatar_src" disabled="disabled" type="hidden"/>
                                        <input class="avatar-data" name="avatar_data" disabled="disabled" type="hidden"/>
                                        <label for="avatarInput">图片上传</label>
                                        <input class="avatar-input" id="avatarInput" name="avatar_file" type="file" />
                                    </div>

                                    <!-- Crop and preview -->
                                    <div class="row">
                                        <div class="col-md-9">
                                            <div class="avatar-wrapper"></div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="avatar-preview preview-lg"></div>
                                            <div class="avatar-preview preview-md"></div>
                                            <div class="avatar-preview preview-sm"></div>
                                        </div>
                                    </div>

                                    <div class="row avatar-btns">
                                        <div class="col-md-9">
                                            <div class="btn-group">
                                                <button class="btn btn-primary" data-method="rotate" data-option="-90" type="button">左转</button>
                                                <button class="btn btn-primary" data-method="rotate" data-option="-15" type="button">左转15°</button>
                                                <button class="btn btn-primary" data-method="rotate" data-option="-30" type="button">左转30°</button>
                                                <button class="btn btn-primary" data-method="rotate" data-option="-45" type="button">左转45°</button>
                                            </div>
                                            <div class="btn-group">
                                                <button class="btn btn-primary" data-method="rotate" data-option="90" type="button">右转</button>
                                                <button class="btn btn-primary" data-method="rotate" data-option="15" type="button">右转15°</button>
                                                <button class="btn btn-primary" data-method="rotate" data-option="30" type="button">右转30°</button>
                                                <button class="btn btn-primary" data-method="rotate" data-option="45" type="button">右转45°</button>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <button class="btn btn-primary btn-block avatar-save avatar-button"  type="button">确定</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                       </div>
                    </div>
                </div>
            </div><!-- /.modal -->
            <!-- Loading state -->
            <!-- <div class="loading" aria-label="Loading" role="img" tabindex="-1"></div> -->
</div>

<script src="__PUBLIC__/corpper/assets/js/jquery.min.js"></script>
<script src="__PUBLIC__/corpper/js/cropper.min.js"></script>
<script src="__PUBLIC__/corpper/js/main.js"></script>
<script>
//编辑时展示原始图片
$(function(){
var batchP,head,imgArray,divstr;
batchP = $('.batchP').val();
head = $('.head').val();
if(head != ''){
	if(batchP==2){
		//多图
		 imgArray = head.split("|");
	     divstr='';
	    for (var i = 0;i<imgArray.length;i++) {
	        if(imgArray[i] != "" || typeof(imgArray[i]) == "undefined"){
	            divstr = divstr + "<div class='icon'><img class='iconimg' src="+ imgArray[i]+" alt='图片' style='width:100%;'/><div class='remove' onclick='remove(this)'>移除</div></div>";
	        }
	    }
	    $('.container').parent().append(divstr);
	}else{
		//单图
		$('.def-imgx').attr('src',head);
	}
	
}		
})
//移除功能使用
function arrange(){
    var ImgStr="";
    $('.iconimg').each(function(index){
        if(index!=0) ImgStr+='|';
        ImgStr+=$(this).attr('src');
    });
    $('.head').val(ImgStr);
}
function remove(t){
	$(t).parent().remove();
	arrange();
}


</script>
